export default {
	common: {
		baseUrl: "http://192.168.0.177:3000", //公司电脑
		// baseUrl: "http://127.0.0.1:3000", //mac
		data: {},
		header: {
			'content-type': 'application/json',
			'content-type': 'application/x-www-form-urlencoded',
		},
		method: 'GET',
		dataType: 'json'
	},
	request(options = {}) {
		// uni.showLoading({
		// 	title: '加载中'
		// });
		options.url = this.common.baseUrl + options.url;
		options.data = options.data || this.common.data;
		options.header = options.header || this.common.header;
		options.method = options.method || this.common.method;
		options.dataType = options.dataType || this.common.dataType;
		return new Promise((resolve, reject) => {
			uni.request({
				...options,
				success: (result) => {
					if (result.statusCode != 200) {
						setTimeout(function() {
							uni.hideLoading();
						}, 500);
						return reject()
					} else {
						setTimeout(function() {
							uni.hideLoading();
						}, 500);
						let data = result.data.data
						resolve(data)
					}
				},
				fail: function(err) {
					uni.hideLoading();
					uni.showToast({
						title: '请求超时！',
						icon: 'none'
					})
				}
			})
		})
	}
}
